package com.yuke.cloud.service.cmc.service.impl;

import com.github.pagehelper.PageHelper;
import com.yuke.cloud.common.core.support.BaseService;
import com.yuke.cloud.common.util.PublicUtil;
import com.yuke.cloud.service.api.cmc.dto.CmsSecKillAndSkuDto;
import com.yuke.cloud.service.api.cmc.dto.CmsSecKillDto;
import com.yuke.cloud.service.api.cmc.dto.CmsSecKillSkuDto;
import com.yuke.cloud.service.api.pmc.dto.ProdSpecInfoDto;
import com.yuke.cloud.service.api.wmc.dto.StorageSpecInfoDto;
import com.yuke.cloud.service.api.wmc.service.WmcStorageFeignApi;
import com.yuke.cloud.service.cmc.dao.CmsAppTopicDataMapper;
import com.yuke.cloud.service.cmc.dao.CmsSecKillMapper;
import com.yuke.cloud.service.cmc.dao.CmsSecKillSkuMapper;
import com.yuke.cloud.service.cmc.dto.CmsAppTopicDataDetailDto;
import com.yuke.cloud.service.cmc.dto.CmsAppTopicInfoDto;
import com.yuke.cloud.service.cmc.dto.CmsAppTopicSpecInfoDto;
import com.yuke.cloud.service.cmc.entity.CmsAppTopicData;
import com.yuke.cloud.service.cmc.entity.CmsSecKill;
import com.yuke.cloud.service.cmc.entity.CmsSecKillSku;
import com.yuke.cloud.service.cmc.service.CmsAppTopicDataService;
import com.yuke.cloud.service.cmc.service.CmsStorageSpecService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;


/**
 * Created by wg on 2019/01/18.
 */
@Slf4j
@Service
@Transactional
public class CmsStorageSpecServiceImpl extends BaseService<CmsAppTopicData> implements CmsStorageSpecService {
    @Resource
    private CmsAppTopicDataMapper cmsAppTopicDataMapper;
    @Resource
    private CmsSecKillMapper cmsSecKillMapper;
    @Resource
    private CmsSecKillSkuMapper cmsSecKillSkuMapper;
    @Resource
    private CmsAppTopicDataService cmsAppTopicDataService;
    @Resource
    private WmcStorageFeignApi wmcStorageFeignApi;



    @Override
    public List<ProdSpecInfoDto> getAppDetailByTopicId(CmsAppTopicDataDetailDto cmsAppTopicDataDetailDto) {
        log.info("--- Enter getAppDetailByTopicId(CmsAppTopicDataDetailDto cmsAppTopicDataDetailDto)，参数：{} ---", cmsAppTopicDataDetailDto.getTopicId());
        List<ProdSpecInfoDto> prodSpecInfoDtos = new ArrayList<>();
        if (cmsAppTopicDataDetailDto == null || cmsAppTopicDataDetailDto.getTopicId() == null || cmsAppTopicDataDetailDto.getTopicId().equals("")) {
            return prodSpecInfoDtos;
        }
        if (cmsAppTopicDataDetailDto!=null){
            if (cmsAppTopicDataDetailDto.getShopId()==null){
                cmsAppTopicDataDetailDto.setShopId(220854931912392704L);
            }
        }

        List<CmsAppTopicDataDetailDto> cmsAppTopicDataDetailDtos = cmsAppTopicDataMapper.getAppListByTopicId(cmsAppTopicDataDetailDto.getTopicId());

        List<Long> specIds = cmsAppTopicDataDetailDtos.stream().map(CmsAppTopicDataDetailDto::getItemId).collect(Collectors.toList());
        if (specIds == null || specIds.size() == 0) {
            log.info("--- 该主题下没有内容 ---");
            return prodSpecInfoDtos;
        }
        StorageSpecInfoDto storageSpecInfoDto = new StorageSpecInfoDto();
        storageSpecInfoDto.setSpecIds(specIds);
        storageSpecInfoDto.setSaleType(cmsAppTopicDataDetailDto.getSaleType());
        Long shopId = cmsAppTopicDataDetailDto.getShopId();

        List<StorageSpecInfoDto> storageSpecInfoDtoList = wmcStorageFeignApi.getStorageInfoByCondition(storageSpecInfoDto,shopId);

        if (storageSpecInfoDtoList == null) {
            log.error("--- wmcStorageFeignApi.getSpecInfoDtosByCondition(prodSpecInfoDto)内部异常，参数：{} ---", storageSpecInfoDtoList.size());
            return prodSpecInfoDtos;
        }
        for (StorageSpecInfoDto item:storageSpecInfoDtoList){
            ProdSpecInfoDto prodSpecInfoDto = new ProdSpecInfoDto();
            BeanUtils.copyProperties(item,prodSpecInfoDto);
            //2020.5.9
            prodSpecInfoDto.setPicture(item.getBigPicture());
            prodSpecInfoDtos.add(prodSpecInfoDto);
        }

        return prodSpecInfoDtos;
    }


    @Override
    public List<CmsAppTopicDataDetailDto> getAppDetailByTopicIdList(CmsAppTopicDataDetailDto cmsAppTopicDataDetailDto) {

        List<CmsAppTopicDataDetailDto> cmsAppTopicDataDetailDtoList = new ArrayList<>();
        if (cmsAppTopicDataDetailDto.getTopicIds() == null || "".equals(cmsAppTopicDataDetailDto.getTopicIds())) {
            log.info("--- 传入的主题id为null ---");
            return cmsAppTopicDataDetailDtoList;
        }
        if (cmsAppTopicDataDetailDto!=null){
            if (cmsAppTopicDataDetailDto.getShopId()==null){
                cmsAppTopicDataDetailDto.setShopId(220854931912392704L);
            }
        }
        List<Long> topicIds = Arrays.asList(cmsAppTopicDataDetailDto.getTopicIds().split(",")).stream().map(topicId -> Long.valueOf(topicId)).collect(Collectors.toList());
        for (Long topicId : topicIds) {
            List<CmsAppTopicDataDetailDto> cmsAppTopicDataDetailDtos = cmsAppTopicDataMapper.getAppListByTopicId(topicId);
            //dataType数据类型，1：商品类；2：厂家类；3：地域类；4：店铺类；5：其他。
            if (cmsAppTopicDataDetailDtos.size() > 0) {
                Integer dataType = cmsAppTopicDataDetailDtos.get(0).getDataType();
                switch (dataType.toString()) {
                    case "1":
                    case "99":
                        log.info("--- dataType数据类型为：1、99，代表：商品类 ---");
                        //cmsAppTopicDataDetailDtos = getProdDetail(cmsAppTopicDataDetailDtos,cmsAppTopicDataDetailDto.getShopId(),cmsAppTopicDataDetailDto.getLongitude(), cmsAppTopicDataDetailDto.getLatitude());
                        cmsAppTopicDataDetailDtos = getProdDetail(cmsAppTopicDataDetailDtos,cmsAppTopicDataDetailDto.getShopId(),"0", "0");
                        break;
                    case "2":
                        log.info("--- dataType数据类型为：2，代表：厂家类 ---");
                        cmsAppTopicDataDetailDtos = cmsAppTopicDataService.getFactoryDetail(cmsAppTopicDataDetailDtos);
                        break;
                    case "3":
                        log.info("--- dataType数据类型为：3，代表：地理信息类 ---");
                        cmsAppTopicDataDetailDtos = cmsAppTopicDataService.getRegionIntroduceInfoByIds(cmsAppTopicDataDetailDtos);
                        break;
                    case "4":
                        log.info("--- dataType数据类型为：4，代表：店铺类 ---");
                        cmsAppTopicDataDetailDtos = cmsAppTopicDataService.getShopDetail(cmsAppTopicDataDetailDtos);
                        break;
                }
                cmsAppTopicDataDetailDtoList.addAll(cmsAppTopicDataDetailDtos);
            } else {
                log.info("--- 该主题下没有内容 ---");
            }
        }
//        log.info("--- Leave getAppDetailByTopicIds(CmsAppTopicDataDetailDto cmsAppTopicDataDetailDto)，返回值：{} ---", cmsAppTopicDataDetailDtoList);

        return cmsAppTopicDataDetailDtoList;
    }

    private List<CmsAppTopicDataDetailDto> getProdDetail(List<CmsAppTopicDataDetailDto> cmsAppTopicDataDetailDtos, Long shopId, String longitude, String latitude) {
        // log.info("--- Enter getProdDetail(List<CmsAppTopicDataDetailDto> cmsAppTopicDataDetailDtos, String longitude, String latitude)方法，参数：{},{},{} ---", cmsAppTopicDataDetailDtos, longitude, latitude);
        List<Long> specIds = cmsAppTopicDataDetailDtos.stream().map(CmsAppTopicDataDetailDto::getItemId).collect(Collectors.toList());
        if (specIds == null || specIds.size() == 0) {
            log.info("--- 该主题下没有内容 ---");
            return cmsAppTopicDataDetailDtos;
        }
        StorageSpecInfoDto storageSpecInfoDto = new StorageSpecInfoDto();
        storageSpecInfoDto.setSpecIds(specIds);

        List<StorageSpecInfoDto> storageSpecInfoDtoList = wmcStorageFeignApi.getStorageInfoByCondition(storageSpecInfoDto,shopId);
        if (storageSpecInfoDtoList == null) {
            log.error("--- pmcFeignApi.getSpecInfoDtosByCondition(prodSpecInfoDto)内部异常，参数：{} ---", storageSpecInfoDtoList);
            return cmsAppTopicDataDetailDtos;
        }

        for (CmsAppTopicDataDetailDto cmsAppTopicDataDetailDto : cmsAppTopicDataDetailDtos) {
            for (StorageSpecInfoDto specInfoDto : storageSpecInfoDtoList) {
                if (specInfoDto.getSpecId().equals(cmsAppTopicDataDetailDto.getItemId())) {
                    ProdSpecInfoDto prodSpecInfo = new ProdSpecInfoDto();
                    BeanUtils.copyProperties(specInfoDto,prodSpecInfo);
                    //2020.5.9
                    prodSpecInfo.setPicture(specInfoDto.getBigPicture());
                    cmsAppTopicDataDetailDto.setProdSpecInfoDto(prodSpecInfo);
                }
            }
        }

        log.info("--- Leave getProdDetail(List<CmsAppTopicDataDetailDto> cmsAppTopicDataDetailDtos, String longitude, String latitude)方法");

        return cmsAppTopicDataDetailDtos;
    }

    @Override
    public List<CmsSecKillAndSkuDto> getSecKillAndSpecs(Integer count, Long shopId){
        List<CmsSecKillAndSkuDto> cmsSecKillAndSkuDtos = getNowSecKillAndSpecs(count,shopId);
        if (cmsSecKillAndSkuDtos == null || cmsSecKillAndSkuDtos.size() <= 0) {
            cmsSecKillAndSkuDtos = getNextSecKillAndSpecs(count,shopId);
            if (cmsSecKillAndSkuDtos == null || cmsSecKillAndSkuDtos.size() <= 0) {
                cmsSecKillAndSkuDtos = getLastSecKillAndSpecs(count,shopId);
            }
        }
        return cmsSecKillAndSkuDtos;
    }


    private List<CmsSecKillAndSkuDto> getNextSecKillAndSpecs(Integer count, Long shopId) {

        List<CmsSecKillAndSkuDto> cmsSecKillAndSkuDtos = new ArrayList<>();
        Example example = new Example(CmsSecKill.class);
        Example.Criteria criteria = example.createCriteria();
        example.setOrderByClause("start_time");
        criteria.andLessThan("secKillType",3);
        Date start = new Date();
        Date end = new Date();
        end.setTime(start.getTime() + 24 * 60 * 60 * 1000 - 1000);

        criteria.andCondition(" UNIX_TIMESTAMP(start_time)<="+start.getTime()/1000);
        criteria.andCondition(" UNIX_TIMESTAMP(end_time)>="+start.getTime()/1000);

        List<CmsSecKill> cmsSecKills = cmsSecKillMapper.selectByExample(example);
        if (cmsSecKills != null && cmsSecKills.size()>0){
            cmsSecKillAndSkuDtos = getSecKillSkuInfo(cmsSecKills, count, shopId);
        }
        return cmsSecKillAndSkuDtos;
    }

    private List<CmsSecKillAndSkuDto> getLastSecKillAndSpecs(Integer count, Long shopId) {

        List<CmsSecKillAndSkuDto> cmsSecKillAndSkuDtos = new ArrayList<>();
        Example example = new Example(CmsSecKill.class);
        Example.Criteria criteria = example.createCriteria();
        example.setOrderByClause("end_time desc");

        Date now = new Date();

        criteria.andEqualTo("isEnable", true);
        criteria.andCondition(" UNIX_TIMESTAMP( end_time ) < " + now.getTime() / 1000 );

        List<CmsSecKill> cmsSecKills = cmsSecKillMapper.selectByExample(example);
        if (cmsSecKills != null && cmsSecKills.size()>0){
            cmsSecKillAndSkuDtos = getSecKillSkuInfo(cmsSecKills, count, shopId);
        }
        return cmsSecKillAndSkuDtos;
    }

    //获取秒杀活动及秒杀商品信息
    private List<CmsSecKillAndSkuDto> getNowSecKillAndSpecs(Integer count, Long shopId) {
        Long warehouseId = wmcStorageFeignApi.getwarehouseinfo(shopId);
        List<CmsSecKillAndSkuDto> cmsSecKillAndSkuDtos = new ArrayList<>();
        Example example = new Example(CmsSecKill.class);
        Example.Criteria criteria = example.createCriteria();
        example.setOrderByClause("start_time");

        Date now = new Date();
        criteria.andEqualTo("warehouseId",warehouseId);
        criteria.andLessThan("secKillType", 3);
        criteria.andEqualTo("isEnable", true);
        criteria.andCondition(" UNIX_TIMESTAMP( start_time ) <= " + now.getTime() / 1000 + " AND " + now.getTime() / 1000 + " <= UNIX_TIMESTAMP( end_time ) ");
        //获取秒杀活动
        List<CmsSecKill> cmsSecKills = cmsSecKillMapper.selectByExample(example);
        if (cmsSecKills != null && cmsSecKills.size()>0){
            //由秒杀活动获取秒杀商品信息
            cmsSecKillAndSkuDtos = getSecKillSkuInfo(cmsSecKills, count, shopId);
        }
        return cmsSecKillAndSkuDtos;
    }

    //由秒杀活动获取秒杀商品信息
    private List<CmsSecKillAndSkuDto> getSecKillSkuInfo(List<CmsSecKill> cmsSecKills, Integer count, Long shopId) {
        List<CmsSecKillAndSkuDto> cmsSecKillAndSkuDtos = new ArrayList<>();
        if (cmsSecKills != null && cmsSecKills.size() > 0) {
            List<Long> ids = cmsSecKills.stream().map(CmsSecKill::getSecKillId).collect(Collectors.toList());
            Example exampleSku = new Example(CmsSecKillSku.class);
            exampleSku.setOrderByClause("sort");
            Example.Criteria criteriaSku = exampleSku.createCriteria();
            criteriaSku.andIn("secKillId", ids);
            if (count != null && count > 0) {
                PageHelper.startPage(0, count);
            }
            //获取秒杀商品信息
            List<CmsSecKillSku> cmsSecKillSkus = cmsSecKillSkuMapper.selectByExample(exampleSku);
            System.out.println("获取秒杀商品信息"+cmsSecKillSkus);
            if (cmsSecKillSkus != null && cmsSecKillSkus.size() > 0) {
                // 获取商品详细信息
                cmsSecKillSkus = getSecKillSkuSpecInfo(cmsSecKillSkus, shopId);
            }
            //将秒杀活动和秒伤商品封装返回cmsSecKillAndSkuDtos
            cmsSecKillAndSkuDtos = getSecKillAndSkuDtos(cmsSecKillSkus,cmsSecKills);
        }
        return cmsSecKillAndSkuDtos;
    }

    // 获取商品详细信息
    private List<CmsSecKillSku> getSecKillSkuSpecInfo(List<CmsSecKillSku> cmsSecKillSkus, Long shopId) {
        List<Long> specIds = cmsSecKillSkus.stream().map(CmsSecKillSku::getSpecId).collect(Collectors.toList());
        // 从wms_storage获取商品信息

        List<StorageSpecInfoDto> prodSpecInfoExDtoList = wmcStorageFeignApi.getProdStorageSpecBySpecIds(specIds,shopId);

        if (prodSpecInfoExDtoList != null) {
            for (CmsSecKillSku cmsSecKillSku : cmsSecKillSkus) {
                for (StorageSpecInfoDto storageSpecInfoDto : prodSpecInfoExDtoList) {
                    if (cmsSecKillSku.getSpecId().equals(storageSpecInfoDto.getSpecId())) {
                        cmsSecKillSku.setWarehouseId(storageSpecInfoDto.getWarehouseId());
                        cmsSecKillSku.setStoreCount(storageSpecInfoDto.getStockCount());
                        cmsSecKillSku.setSaledCount(Integer.parseInt(storageSpecInfoDto.getSaleCount().toString()));
                        cmsSecKillSku.setSpecName(storageSpecInfoDto.getSpecName());
                        cmsSecKillSku.setStorageId(storageSpecInfoDto.getStorageId());
                        cmsSecKillSku.setWeight(storageSpecInfoDto.getWeight());
                        cmsSecKillSku.setProductId(storageSpecInfoDto.getProductId());
                        cmsSecKillSku.setWarehouseId(storageSpecInfoDto.getWarehouseId());
                        cmsSecKillSku.setWareCityId(storageSpecInfoDto.getWareCityId());
                        cmsSecKillSku.setWareCityName(storageSpecInfoDto.getWareCityName());

                        //todo 20191029修改，将getSalePrice() 改为getGuidancePrice();
                        cmsSecKillSku.setMarketPrice(storageSpecInfoDto.getGuidancePrice());
                        //todo 20191029修改，将SecKillPrice 改为.getSalePrice();
                        if (cmsSecKillSku.getSecKillId().equals(3L)){
                            cmsSecKillSku.setSecKillPrice(storageSpecInfoDto.getStockPrice());
                        }else{
                            cmsSecKillSku.setSecKillPrice(storageSpecInfoDto.getSalePrice());
                        }
                        if (PublicUtil.isEmpty(cmsSecKillSku.getPicUrl())) {
                            cmsSecKillSku.setPicUrl(storageSpecInfoDto.getBigPicture());
                        }
                        break;
                    }
                }
            }
        }

        return cmsSecKillSkus;
    }

    //将秒杀活动和秒伤商品封装返回cmsSecKillAndSkuDtos
    private List<CmsSecKillAndSkuDto> getSecKillAndSkuDtos(List<CmsSecKillSku> cmsSecKillSkus, List<CmsSecKill> cmsSecKills) {
        List<CmsSecKillAndSkuDto> cmsSecKillAndSkuDtos = new ArrayList<>();
        for (CmsSecKill cmsSecKill : cmsSecKills) {
            CmsSecKillAndSkuDto cmsSecKillAndSkuDto = new CmsSecKillAndSkuDto();
            CmsSecKillDto cmsSecKillDto = new CmsSecKillDto();
            BeanUtils.copyProperties(cmsSecKill, cmsSecKillDto);
            cmsSecKillAndSkuDto.setCmsSecKillDto(cmsSecKillDto);

            List<CmsSecKillSkuDto> cmsSecKillSkuDtos = new ArrayList<>();
            for (CmsSecKillSku cmsSecKillSku : cmsSecKillSkus) {
                if (cmsSecKillSku.getSecKillId().equals(cmsSecKill.getSecKillId())){
                    CmsSecKillSkuDto cmsSecKillSkuDto = new CmsSecKillSkuDto();
                    BeanUtils.copyProperties(cmsSecKillSku, cmsSecKillSkuDto);

                    cmsSecKillSkuDtos.add(cmsSecKillSkuDto);
                }

            }
            cmsSecKillAndSkuDto.setCmsSecKillSkuDtos(cmsSecKillSkuDtos);

            cmsSecKillAndSkuDtos.add(cmsSecKillAndSkuDto);
        }


        return cmsSecKillAndSkuDtos;
    }

    @Override
    public List<CmsSecKillSkuDto> getSecKillSkus(Long secKillId,Long shopId) {
        //由秒杀活动secKillId获得秒杀商品信息
        List<CmsSecKillSkuDto> cmsSecKillSkuDtos = new ArrayList<>();
        Example exampleSku = new Example(CmsSecKillSku.class);
        exampleSku.setOrderByClause("sort");
        Example.Criteria criteriaSku = exampleSku.createCriteria();
        criteriaSku.andEqualTo("secKillId", secKillId);
        criteriaSku.andEqualTo("isEnable",true);

        List<CmsSecKillSku> cmsSecKillSkus = cmsSecKillSkuMapper.selectByExample(exampleSku);

        if (cmsSecKillSkus != null && cmsSecKillSkus.size() > 0) {
            // 获取商品信息
            cmsSecKillSkus = getSecKillSkuSpecInfo(cmsSecKillSkus,shopId);

            for (CmsSecKillSku cmsSecKillSku : cmsSecKillSkus) {
                CmsSecKillSkuDto cmsSecKillSkuDto = new CmsSecKillSkuDto();
                BeanUtils.copyProperties(cmsSecKillSku, cmsSecKillSkuDto);
                cmsSecKillSkuDto.setStockCount(cmsSecKillSkuDto.getStoreCount());
                cmsSecKillSkuDtos.add(cmsSecKillSkuDto);
            }
        }
        return cmsSecKillSkuDtos;
    }


    @Override
    public List<CmsAppTopicSpecInfoDto> getAppTopicSpecInfoList(CmsAppTopicInfoDto cmsAppTopicInfoDto) {

        List<CmsAppTopicSpecInfoDto> cmsAppTopicSpecInfoDtoList = new ArrayList<>();
        if (cmsAppTopicInfoDto.getTopicId() == null ) {
            log.info("--- 传入的主题id为null ---");
            return cmsAppTopicSpecInfoDtoList;
        }

        Example example = new Example(CmsAppTopicData.class);
        Example.Criteria criteria = example.createCriteria();
        example.setOrderByClause("sort asc");
        criteria.andEqualTo("topicId", cmsAppTopicInfoDto.getTopicId());
        List<CmsAppTopicData> cmsAppTopicDataList = cmsAppTopicDataMapper.selectByExample(example);

        //getTopicType数据类型，1：商品类；2：厂家类；3：地域类；4：店铺类；5：其他。
        if (cmsAppTopicInfoDto.getTopicType().toString().equals("1") || cmsAppTopicInfoDto.getTopicType().toString().equals("99")) {
            List<Long> specIds = cmsAppTopicDataList.stream().map(CmsAppTopicData::getItemId).collect(Collectors.toList());
            if (specIds == null || specIds.size() == 0) {
                return cmsAppTopicSpecInfoDtoList;
            }

            //List<StorageSpecInfoDto> storageSpecInfoDtoList = wmcStorageFeignApi.getStorageInfoByCondition(storageSpecInfoDto, cmsAppTopicInfoDto.getShopId());
            List<StorageSpecInfoDto> storageSpecInfoDtoList = wmcStorageFeignApi.getStorageInfoBySpecIds(specIds, cmsAppTopicInfoDto.getShopId());

            if (storageSpecInfoDtoList == null) {
                log.error("--- wmcStorageFeignApi.getStorageInfoBySpecIds(specIds,cmsAppTopicInfoDto.getShopId())内部异常，参数：{} ---", storageSpecInfoDtoList);
                return cmsAppTopicSpecInfoDtoList;
            }

            for (CmsAppTopicData appTopicData : cmsAppTopicDataList) {
                for (StorageSpecInfoDto specInfoDto : storageSpecInfoDtoList) {
                    if (specInfoDto.getSpecId().equals(appTopicData.getItemId())) {
                        CmsAppTopicSpecInfoDto appTopicSpecInfoDto = new CmsAppTopicSpecInfoDto();
                        BeanUtils.copyProperties(specInfoDto, appTopicSpecInfoDto);
                        BeanUtils.copyProperties(appTopicData, appTopicSpecInfoDto);
                        //zyq   bigPicture->Picture
                        appTopicSpecInfoDto.setPicUrl(appTopicData.getPicUrl());
                        appTopicSpecInfoDto.setPicture(specInfoDto.getBigPicture());
                        appTopicSpecInfoDto.setSaleCount(specInfoDto.getSaleCount());
                        cmsAppTopicSpecInfoDtoList.add(appTopicSpecInfoDto);
                    }
                }
            }
        }else{
            for (CmsAppTopicData appTopicData : cmsAppTopicDataList) {
                CmsAppTopicSpecInfoDto appTopicSpecInfoDto = new CmsAppTopicSpecInfoDto();
                BeanUtils.copyProperties(appTopicData, appTopicSpecInfoDto);
                cmsAppTopicSpecInfoDtoList.add(appTopicSpecInfoDto);
            }
        }

        return cmsAppTopicSpecInfoDtoList;
    }
}
